package com.hopu.oa.dao.role;

import com.hopu.oa.entity.user.AoaRole;
import com.hopu.oa.entity.user.AoaRolePowerList;
import com.hopu.oa.entity.user.AoaUserLoginRecord;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 角色管理
 */
@Repository
@Mapper
public interface roleDao {
    /**
     * 角色管理主页搜索分页
     *
     * @param roleName
     * @param index
     * @param size
     * @return
     */
    List<AoaRole> selectAllRole(@Param("roleName") String roleName, @Param("index") Integer index, @Param("size") Integer size);

    /**
     * 角色名称验重
     *
     * @param roleName
     * @return
     */
    @Select("select * from aoa_role_ where role_name = #{roleName}")
    AoaRole selectRoleByRoleName(String roleName);

    @Select("select * from aoa_role_ where role_id = #{roleId}")
    AoaRole selectRoleByRoleId(Integer roleId);

    /**
     * 新增角色
     *
     * @return
     */
    @Insert("insert into aoa_role_ (role_name) values(#{roleName})")
    int insertRole(AoaRole aoaRole);

    @Insert("insert into aoa_role_power_list (is_show,menu_id,role_id) values(#{roleId})")
    int insertRolePowwerList();

    /**
     * 修改角色名称
     *
     * @return
     */
    @Update("update aoa_role_ set role_name = #{roleName} where role_id = #{roleId}")
    int updateRole(AoaRole aoaRole);

    /**
     * 删除角色
     *
     * @return
     */
    @Delete("delete from aoa_role_ where role_id = #{roleId}")
    int deleteRoleAndRoleList(@Param("roleId") Integer roleId);

    @Insert("insert into aoa_role_ (role_Name)values(#{roleName})")
    int isnertRole(AoaRole aoaRole);

    int insertRoleList(@Param("list") List<Integer> list, @Param("roleId") Integer roleId);

}
